******************************
*Table A7: ITT effects of the DFS treatment on child attendance, by sub-groups
************************
clear all
set trace off
set more off
use Jehanabad_analytic_sample_cognition
label variable hemoglobin "child hemoglobin level"

global socio_cov_4_vari no_HHmembers years_schooling_father years_schooling_mother asset_index

global school_cov_4_vari total_enrollment class_size student_teacher_ratio

g post=wave
label var post "Post"  /* Post denotes endline survey */
g treat_post=treat*post
label var treat_post "Treat*post"
label var treat "Treat"


sort child_unique wave
g base_hb=hemoglobin
replace base_hb=hemoglobin[_n-1] if wave==1
g bl_anemic= base_hb < 11.5
g non_anemic =(base_hb >=11.5)

egen howmany = count(total_attendance_2 ), by (child_unique)


xtset child_unique wave
xtreg total_attendance_2 treat_post treat post $socio_cov_1_vari $school_cov_4_vari if howmany==2, fe cluster (school_id)
outreg2 using tableA7.doc, word replace ctitle(Full, sample) dec(3) keep(treat_post post treat) nocons nor2 ///
title(Table A7: ITT effects of the DFS treatment on child attendance, by sub-groups) nonotes ///
addnote("Notes: Standard errors, clustered at the school level, are reported in parentheses. Estimated coefficients are based on" ///
"a DD model estimated separately in each column. All regressions include child fixed effects and time-variant household and school-level controls" ///
"reported in Table A5. *, **, *** denote significance at the 10%, 5%, and 1% levels, respectively.") 


xtreg total_attendance_2 treat_post treat post $socio_cov_1_vari $school_cov_4_vari if bl_anemic==1 & howmany==2, fe cluster (school_id)
outreg2 using tableA7.doc, word append ctitle(Baseline, anemic) dec(3) keep(treat_post post treat) nocons nor2 

xtreg total_attendance_2 treat_post treat post $socio_cov_1_vari $school_cov_4_vari if bl_anemic==0 & howmany==2, fe cluster (school_id)
outreg2 using tableA7.doc, word append ctitle(Non-anemic) dec(3) keep(treat_post post treat) nocons nor2 

xtreg total_attendance_2 treat_post treat post $socio_cov_1_vari $school_cov_4_vari if sex_child==0 & howmany==2, fe cluster (school_id)
outreg2 using tableA7.doc, word append ctitle(Girls) dec(3) keep(treat_post post treat) nocons nor2 

xtreg total_attendance_2 treat_post treat post $socio_cov_1_vari $school_cov_4_vari if sex_child==1 & howmany==2, fe cluster (school_id)
outreg2 using tableA7.doc, word append ctitle(Boys) dec(3) keep(treat_post post treat) nocons nor2 

********************************************End of do file *******************


